<%@page import="com.ids.bean.UserInfo"%>
<%@page import="java.util.GregorianCalendar"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@page import="java.util.Calendar"%>
<script type="text/javascript" charset="utf-8">
			
$(document).ready(function () {
 
  	 $('#monthSelection, #yearSelection, #isMultiLevel').change(function(){
  		
    	 showDetailedAttendance("no");
   	});
  	$('#ReportGeneration').click(function(){
   		
     	showDetailedAttendance("yes");
  	 });     
       
 });
      
  function showDetailedAttendance(toBeExported){
  
       
       var postDataMonth = $('#monthSelection').val();
       var postDataYear = $('#yearSelection').val(); 
       var postDataToBeExported = toBeExported;
        $.ajax({
        	type: "POST",                             
        	url: "EmployeeSpecificMonthAttendance",
        	data: {"isMultiLevelValue":document.getElementById("isMultiLevel").checked ,"monthSelection":postDataMonth ,"yearSelection":postDataYear, "toBeExported":postDataToBeExported  },
        	success: function(msg){
        		$('#showEmployeeAttendance').html(msg); 
   			}
 		 });
   }
</script>
<%
String currentMonth = request.getParameter("monthSelection");
String currentYear = request.getParameter("yearSelection");
String isMultilevelInReq =request.getParameter("isMultiLevel");
System.out.println(isMultilevelInReq );
%>



<table width="100%">
	<tr>
		<td align="left">
		<%
			if (isLeadOrManager) {
		 		%> <s:if test="isLeadOrManager=true">
		 		<b>Show all subordinates</b>
		 		<input type="checkbox" name="isMultiLevel" id="isMultiLevel" title="Show all subordinates" value="1" />
		</s:if> </td><%} else {%>
		<input type="hidden" name="isMultiLevel" id="isMultiLevel" title="Show all subordinates" value="true"  />
		<%} %>
		<td align="right" width="7%"><a href="<s:url action="ExportReport">
		 											<s:param name="month">  
                     									<s:property value="currentMonth" />  
                 									</s:param>
                 									<s:param name="year">  
                     									<s:property value="currentYear" />  
                 									</s:param>
                 									<s:param name="isMultiplelevel">  
                     									<s:property value="isMultilevelInReq" />  
                 									</s:param>
                 									               									
                 									</s:url>">Export</a></td>
		<td align="right" width="4%">
		<s:select list="yearsList" listKey="key"
					listValue="value"  theme="simple" value="CurrentYear" id="yearSelection" name="yearSelection"></s:select>
		</td>			
		<td align="right" width="10%">
		<s:select list="monthsList" listKey="key"
					listValue="value"  theme="simple" value="CurrentMonth" id="monthSelection" name="monthSelection"></s:select>
		
		</td>
	</tr>
</table>

<div id="showEmployeeAttendance">
<s:form action="ExportReport">
<table  class="borderAllEmp" border="0" style="width:100%">
	<tr background="images/headerBg.JPG" >
	<td width="10%" style="font-weight: bold" colspan="1" >ECode </td>
	<td width="30%" style="font-weight: bold" colspan="1" >Name</td>
		<s:iterator value="attendanceStatistics" >
		<td align="center" colspan="3" style="font-weight: bold" ><s:property /></td>
		</s:iterator>
		<s:iterator value="weekDays">
			<td align="center" colspan="3" style="font-weight: bold" ><s:property />
			</td>
		</s:iterator>
	</tr>
	<tr>
		<td width="10%"></td>
		<td width="30%"></td>
		<td width="30%" colspan="27"></td>
		<s:iterator value="months">
		<td align="center" colspan="3"><s:property /></td>
		</s:iterator>
	</tr>
	<s:iterator value="employeeAttandence">
		<%int i=0; %>
		<tr>
			<td colspan="1"><s:property value="key.substring(0,5)" /></td>
			<td colspan="1"><s:property value="key.substring(6)" /></td>
			<s:iterator value="value.attendanceGraph" >
				<td align="center" colspan="3" class='b<%=i%>' ><s:property /></td>
			<% i++; %>
			</s:iterator>
			<s:iterator value="value.employeeAttandence">
				<td class='c<s:property value="attandenceTypeId"/>'>&nbsp;</td>
				<td class='c<s:property  value="dependantAttendanceTypeId"/>'>&nbsp;</td>
				<td></td>
				
			</s:iterator>
		</tr>
		<tr>
			<td></td>
		</tr>
	</s:iterator>
	<tr>
			<td></td>
		</tr>
</table>

</s:form>
</div>
        
<div style="position:relative; display:block">
<b>Legends:</b>
<table  >
            
	<tr>
		<td class='c0' >&nbsp;&nbsp;</td>
		<td>No Data</td>
		<td  >&nbsp;&nbsp;</td>
		<td  >P</td>
		<td  >-</td>
		<td>Present</td>
	</tr>
	<tr>
		<td class='c1' ></td>
		<td>Leaves</td>
		<td  >&nbsp;&nbsp;</td>
		<td  >SL</td>
		<td  >-</td>
		<td>Sick Leave</td>
	</tr>
	<tr>
		<td class='c2' ></td>
		<td>Present</td>
		<td  >&nbsp;&nbsp;</td>
		<td  >CL</td>
		<td  >-</td>
		<td>Casual Leave</td>
	</tr>
	<tr>
		<td class='c4'></td>
		<td>LWP</td>
		<td  >&nbsp;&nbsp;</td>
		<td >PL</td>
		<td  >-</td>
		<td>Leave</td>
	</tr>
	<tr>
		<td class='c5'></td>
		<td>Short Leave</td>
		<td  >&nbsp;&nbsp;</td>
		<td >CO</td>
		<td  >-</td>
		<td>Comp Off</td>
	</tr>
	<tr>
		<td class='c6'></td>
		<td>Weekly Off</td>
		<td  >&nbsp;&nbsp;</td>
		<td >WO</td>
		<td  >-</td>
		<td>Week Off</td>
	</tr>
	<tr>
		<td class='c7'></td>
		<td>Holiday</td>
		<td  >&nbsp;&nbsp;</td>
		<td >SH</td>
		<td  >-</td>
		<td>Short Leave</td>
	</tr>
	<tr>
		<td class='c100'></td>
		<td>Pending</td>
		<td  >&nbsp;&nbsp;</td>
	</tr>
</table>
</div>
